<%@ page import="com.yusheng.entity.ApprovalRecordList" %>
<%@ page import="com.yusheng.entity.ApprovalRecord" %>
<%@ page import="com.google.gson.Gson" %><%--
  Created by IntelliJ IDEA.
  User: Hello
  Date: 2021/6/8
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>
        审批人审批的详情页展示
    </title>
    <style>
        td{border:solid #add9c0; border-width:0px 1px 1px 0px; text-align: center;
            font-size: small;}
        th{border:solid #add9c0; border-width:0px 1px 1px 0px;}
        table{border:1px solid   #add9c0;  border-collapse: collapse;}
        /* 宽度顺序应该是  上下右左    border-collapse: collapse;代表边框重叠的时候要合并 */
        input{
            width: 15%;
        }
    </style>
</head>
<body style="width: 100%;height: 100%;margin-left: 0px;margin-top: 0px;">
<%
    //获取数据
    ApprovalRecordList approvalRecordList=(ApprovalRecordList) request.getAttribute("approvalList");
%>
<script>
    <%
        Gson gson=new Gson();
        String json=gson.toJson(approvalRecordList);
    %>
    var s='<%=json%>';


    window.onload=function (){
        //alert(s);
        var tbody=document.getElementById("tbody");
        var button_no=document.getElementById("button_no");
        var button_fail=document.getElementById("button_fail");
        var reason=document.getElementById("reason");
        var button_success=document.getElementById("button_success");
        //var tbody=document.getElementById("tbody");
        window.eval("var approval="+s);
        var showNo=function (){
            //alert(1);
            tbody.innerHTML="";
            button_no.style="background-color: aqua;";
            button_fail.style="background-color: none;";
            button_success.style="background-color: none;";
            reason.style="display: none;";
            var s=approval.approvalRecordList;

            var body="";
            for(var approvalRecord in s ){
                if (s[approvalRecord].finished=="未审批"){
                    var url='/approvalProcess/showApproval?recordno='+s[approvalRecord].recordNo;
                    //alert(url);
                    body+="<tr>"+
                        "<td> <a href="+url+">"+ s[approvalRecord].recordNo+"</a></td>"+
                        "<td>"+ s[approvalRecord].stuffName+"</td>"+
                        "<td>"+ s[approvalRecord].recordName+"</td>"+
                        "<td>"+ s[approvalRecord].time+"</td>"+
                        "<td>"+ s[approvalRecord].finished+"</td>"+
                        "<td>"+ s[approvalRecord].recordOpinin+"</td>"
                        +"</tr>";
                }else {
                    continue;
                }
            }
            tbody.innerHTML=body;
        }
        var showFail=function (){
            tbody.innerHTML="";

            var s=approval.approvalRecordList;
            button_fail.style="background-color: aqua;";
            //alert("fail");
            button_no.style="background-color: none;";
            button_success.style="background-color: none;";
            reason.style="display: table-cell;";
            reason.innerText="驳回原因"
            var body="";
            for(var approvalRecord in s ){

                if (s[approvalRecord].finished=="审批没通过"){
                    body+="<tr>"+
                        "<td>"+ s[approvalRecord].recordNo+"</td>"+
                        "<td>"+ s[approvalRecord].stuffName+"</td>"+
                        "<td>"+ s[approvalRecord].recordName+"</td>"+
                        "<td>"+ s[approvalRecord].time+"</td>"+
                        "<td>"+ s[approvalRecord].finished+"</td>"+
                        "<td>"+ s[approvalRecord].recordOpinin+"</td>"+
                        "<td>"+ s[approvalRecord].recordOpinion1+"</td>"
                        +"</tr>";
                }else {
                    continue;
                }
            }
            tbody.innerHTML=body;
        }
        var showSuccess=function (){
            //alert("sunccess")

            var s=approval.approvalRecordList;
            button_success.style="background-color: aqua;";
            button_fail.style="background-color: none;";
            button_no.style="background-color: none;";
            reason.style="display: table-cell;";
            reason.innerText="审批意见";
            var body="";
            for(var approvalRecord in s ){
                //alert(s[approvalRecord].finished);
                if (s[approvalRecord].finished=="审批通过"){
                    body+="<tr>"+
                        "<td>"+ s[approvalRecord].recordNo+"</td>"+
                        "<td>"+ s[approvalRecord].stuffName+"</td>"+
                        "<td>"+ s[approvalRecord].recordName+"</td>"+
                        "<td>"+ s[approvalRecord].time+"</td>"+
                        "<td>"+ s[approvalRecord].finished+"</td>"+
                        "<td>"+ s[approvalRecord].recordOpinin+"</td>"+
                        "<td>"+ s[approvalRecord].recordOpinion1+"</td>"
                        +"</tr>";
                }else {
                    continue;
                }
            }
            tbody.innerHTML=body;
        }
        showNo();
        button_no.onclick=function (){
            showNo();
        }
        button_fail.onclick=function (){
            showFail();
        }
        button_success.onclick=function (){
            //alert("dsjkadj");
            showSuccess();
        }

    }

</script>


<div  style="width: 90%; margin-left: 5%;"> <input type="button"  id="button_no" value="未审批">
    <input type="button" id="button_fail" value="驳回">
    <input type="button"  id="button_success" value="审批通过">

</div>
<table align="center" style="width: 90%;">
    <thead>
    <tr>
        <th>申请编号</th>
        <th>申请人</th>
        <th>申请名称</th>
        <th>申请时间</th>
        <th>是否通过</th>
        <th>申请详情</th>
        <th style="display: none;" id="reason">驳回原因</th>
    </tr>
    </thead>
    <tbody id="tbody">

    </tbody>
</table>
</body>
</html>
